package com.qiang.provider.user;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping(value = "user")
public class UserController {

    @GetMapping(value = "/{id}")
    public UserDto findById(@PathVariable(value = "id") String id) {
        UserDto userDto = new UserDto();
        userDto.setName("张三");
        userDto.setAge(20);
        return userDto;
    }

    @GetMapping(value = "/")
    public List<UserDto> findAll() {
        UserDto userDto = new UserDto();
        userDto.setName("张三");
        userDto.setAge(20);
        ArrayList<UserDto> res = new ArrayList<>();
        res.add(userDto);
        res.add(new UserDto("lisi", 22));
        res.add(new UserDto("wangwu", 30));
        return res;
    }
}
